<%--
  Created by IntelliJ IDEA.
  User: 兰宦君
  Date: 2015/10/21
  Time: 14:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html>
<head>
    <title>网上书店</title>
  <%@ include file="../layout/import.jsp"%>
  <script language="JavaScript">
    function resetPassword(oldpassword,newpassword,newpasswordagain){
      if(newpassword!=newpasswordagain){
        $('#checknewpassword').html("<span class='text-danger'>两次密码不一致</span>");
      }else{
        $.ajax({
          url: "/resetPassword.do",
          data: {
            userid:${userid},
            oldpassword:oldpassword,
            newpassword:newpassword
          },
          method: "POST",
          dataType: "json",
          success: function (response) {
            if(response.code == -1) {
              $('#checkpassword').html("<span class='text-success'>密码错误</span>");
            }else if(response.code==0){
              alert("密码修改成功！");
              window.location.href = "/userinfoedit.do";
            }
          }
        });
      }
    }

    function submit()
    {
      $.ajax({
        url: "/edituserinfo.do",
        data: $('#newuserinfo').serialize(),
        method: "POST",
        dataType: "json",
        error: function () {
          alert("表单提交出错，请稍后再试");
        },
        success: function(response) {
          if(response.code == 0) {
            alert("修改成功");
            window.location.href = "/userinfoedit.do";
          }
          else {
            alert(response.description);
          }
        }
      });
    }
  </script>
</head>

<body>
<%@include file="nav.jsp"%>
<div class="container" style="min-height: 75%">
  <div class="row-fluid">
    <div class="col-sm-12">
      <form class="form-horizontal" id="newuserinfo">
        <div class="form-horizontal">
          <label class="col-sm-2" for="gender">性别</label>
          <div class="controls">
            <select class="form-control" id="gender" name="gender">
              <option <c:if test="${gender == '男'}">selected="selected"</c:if> >男</option>
              <option <c:if test="${gender == '女'}">selected="selected"</c:if> >女</option>
            </select>
          </div>
        </div>
        <div class="form-horizontal">
          <label class="control-label" for="address">地址</label>
          <div class="controls">
            <input type="text" class="form-control" id="address" name="address" placeholder="请输入新地址" value="${user.address}">
          </div>
        </div>
        <div class="form-horizontal">
          <label class="control-label" for="phone">电话</label>
          <div class="controls">
            <input type="number" class="form-control" id="phone" name="phone" placeholder="请输入新电话号码" value="${user.phone}">
          </div>
        </div>
        <div class="form-horizontal">
          <label class="control-label" for="email">邮箱</label>
          <div class="controls">
            <input type="email" class="form-control" id="email" name="email" placeholder="请输入新邮箱" value="${user.email}">
          </div>
        </div>
        <div class="form-horizontal">
          <label class="control-label" for="postcode">邮编</label>
          <div class="controls">
            <input type="number" class="form-control" id="postcode" name="postcode" placeholder="请输入新邮编" value="${user.postcode}">
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
<%@include file="footer.jsp"%>
</body>
</html>
